package com.you.learning.springcloud.order.controller;

import com.you.learning.springcloud.order.entity.Order;
import com.you.learning.springcloud.order.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private IOrderService orderService;

    @GetMapping("/testOrder")
    public String testOrder(int id, String name) {
        System.out.println("---------testOrder------------");
        return "test order method!";
    }

    @RequestMapping("/saveOrder")
    public String saveOrder(String orderNo, String orderName) {
        Order order = new Order();
        order.setOrderNo(orderNo);
        order.setOrderName(orderName);
        orderService.saveOrder(order);
        return "插入了订单" + orderNo;
    }

    @RequestMapping("/saveOrderWithArgs")
    public String saveOrder(String orderNo, String orderName, String exchangeName,String routeKey) {
        Order order = new Order();
        order.setOrderNo(orderNo);
        order.setOrderName(orderName);
        orderService.saveOrder(order, exchangeName,routeKey);
        return "插入了订单" + orderNo;
    }
}
